package glin

import (
	"time"

	"github.com/gorilla/sessions"
)

// 全局的session对象
var StoreSessions sessions.Store

// 全局的session
//var storeSessions = sessions.NewCookieStore([]byte(GDefaultConfig.Session.Secretkey))

// 必须设置session
func Sessioner() MiddlewareFunc {

	return sessionWithConfig()
}

func sessionWithConfig() MiddlewareFunc {
	return func(next HandlerFunc) HandlerFunc {
		return func(c Context) error {
			session, _ := StoreSessions.Get(c.Request(), GDefaultConfig.Session.SessionId)
			c.Set("glin", session)
			return next(c)
		}
	}
}

// 鉴权的数据格式
type AuthAccount struct {
	Data []byte
	Time time.Time //操作时间
}
